/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package ComponenteEntidad;

import java.io.Serializable;
import java.util.List;
import javax.persistence.Basic;
import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.OneToMany;
import javax.persistence.OneToOne;
import javax.persistence.Table;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Size;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlTransient;

/**
 *
 * @author Marilyn
 */
@Entity
@Table(name = "cliente")
@XmlRootElement
@NamedQueries({
    @NamedQuery(name = "Cliente.findAll", query = "SELECT c FROM Cliente c"),
    @NamedQuery(name = "Cliente.findByIdPersona", query = "SELECT c FROM Cliente c WHERE c.idPersona = :idPersona"),
    @NamedQuery(name = "Cliente.findByCliRUC", query = "SELECT c FROM Cliente c WHERE c.cliRUC = :cliRUC"),
    @NamedQuery(name = "Cliente.findByCliRazSoc", query = "SELECT c FROM Cliente c WHERE c.cliRazSoc = :cliRazSoc"),
    @NamedQuery(name = "Cliente.findByCliDireccionFiscal", query = "SELECT c FROM Cliente c WHERE c.cliDireccionFiscal = :cliDireccionFiscal"),
    @NamedQuery(name = "Cliente.findByPerEstado", query = "SELECT c FROM Cliente c WHERE c.perEstado = :perEstado")})
public class Cliente implements Serializable {
    private static final long serialVersionUID = 1L;
    @Id
    @Basic(optional = false)
    @NotNull
    @Column(name = "idPersona")
    private Integer idPersona;
    @Basic(optional = false)
    @NotNull
    @Size(min = 0, max = 15)
    @Column(name = "cli_RUC")
    private String cliRUC;
    @Basic(optional = false)
    @NotNull
    @Size(min = 0, max = 100)
    @Column(name = "cli_RazSoc")
    private String cliRazSoc;
    @Basic(optional = false)
    @NotNull
    @Size(min = 0, max = 250)
    @Column(name = "cli_DireccionFiscal")
    private String cliDireccionFiscal;
    @Column(name = "per_Estado")
    private Boolean perEstado;
    @OneToMany(cascade = CascadeType.ALL, mappedBy = "cliente", fetch = FetchType.LAZY)
    private List<Detallecliente> detalleclienteList;
    @JoinColumn(name = "idPersona", referencedColumnName = "idPersona", insertable = false, updatable = false)
    @OneToOne(optional = false, fetch = FetchType.LAZY)
    private Persona persona;

    public Cliente() {
    }

    public Cliente(Integer idPersona) {
        this.idPersona = idPersona;
    }

    public Cliente(Integer idPersona, String cliRUC, String cliRazSoc, String cliDireccionFiscal) {
        this.idPersona = idPersona;
        this.cliRUC = cliRUC;
        this.cliRazSoc = cliRazSoc;
        this.cliDireccionFiscal = cliDireccionFiscal;
    }

    public Integer getIdPersona() {
        return idPersona;
    }

    public void setIdPersona(Integer idPersona) {
        this.idPersona = idPersona;
    }

    public String getCliRUC() {
        return cliRUC;
    }

    public void setCliRUC(String cliRUC) {
        this.cliRUC = cliRUC;
    }

    public String getCliRazSoc() {
        return cliRazSoc;
    }

    public void setCliRazSoc(String cliRazSoc) {
        this.cliRazSoc = cliRazSoc;
    }

    public String getCliDireccionFiscal() {
        return cliDireccionFiscal;
    }

    public void setCliDireccionFiscal(String cliDireccionFiscal) {
        this.cliDireccionFiscal = cliDireccionFiscal;
    }

    public Boolean getPerEstado() {
        return perEstado;
    }

    public void setPerEstado(Boolean perEstado) {
        this.perEstado = perEstado;
    }

    @XmlTransient
    public List<Detallecliente> getDetalleclienteList() {
        return detalleclienteList;
    }

    public void setDetalleclienteList(List<Detallecliente> detalleclienteList) {
        this.detalleclienteList = detalleclienteList;
    }

    public Persona getPersona() {
        return persona;
    }

    public void setPersona(Persona persona) {
        this.persona = persona;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (idPersona != null ? idPersona.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof Cliente)) {
            return false;
        }
        Cliente other = (Cliente) object;
        if ((this.idPersona == null && other.idPersona != null) || (this.idPersona != null && !this.idPersona.equals(other.idPersona))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "ComponenteEntidad.Cliente[ idPersona=" + idPersona + " ]";
    }
    
}
